package com.grape.juc.lock.reentrant;

/**
 * 描述:Synchronized可重入
 * @author: myx
 * @date: 2019-05-08
 * Copyright © 2019-grape. All rights reserved.
 */
public class SynchronizedLockTest implements Runnable{

    public  synchronized void get() {
        System.out.println("name:" + Thread.currentThread().getName() + " get();");
        set();
    }
    public synchronized  void set() {
        System.out.println("name:" + Thread.currentThread().getName() + " set();");
    }

    @Override
    public void run() {
        get();
    }
    public static void main(String[] args) {
        SynchronizedLockTest ss = new SynchronizedLockTest();
        new Thread(ss).start();
        new Thread(ss).start();
        new Thread(ss).start();
        new Thread(ss).start();
    }
}
